package com.example.cny;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import androidx.multidex.MultiDex;

import com.blankj.utilcode.util.SPUtils;
import com.example.mylibrary.base.BaseApplication;
import com.example.mylibrary.db.gen.Constant;
import com.example.mylibrary.utils.SystemUtil;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.log.LoggerInterceptor;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;

/**
 * Created by mark.liu on 2017-12-2.
 */
public class MyApplication extends BaseApplication {

//    private DBOpenHelper mDBOpenHelper ;
//    private SQLiteDatabase mSQLiteDatabase;
//    private DaoMaster mDaoMaster;
//    private DaoSession mDaoSession ;

    private static MyApplication myApplication;


//    public DaoMaster getMaster() {
//        return mDaoMaster;
//    }
//
//    public DaoSession getSession() {
//        return mDaoSession;
//    }

//    public DaoSession getNewSession() {
//        mDaoSession = mDaoMaster.newSession();
//        return mDaoSession;
//    }

//    public SQLiteDatabase getSQLiteDatabase() {
//        return mSQLiteDatabase;
//    }

    @Override
    public void onCreate() {
        super.onCreate();
        myApplication = this;
        //bugly 初始化
//        Bugly.init(getApplicationContext(), "c0cf01fe05", false);
//        Bugly.init(getApplicationContext(), "c7cb844cdf", false);

//        VpsAgent.init(this,"edbb7e64-32b8-4a28-8546-456269e7291f","xq020");
//        MMKV.initialize(this);
        initUtils();
    }


    private void initUtils() {
//        setDatabase();
        initOkHttp();
    }


    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

    private void initOkHttp() {
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .addInterceptor(new LoggerInterceptor("OkHttpUtils"))
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                //其他配置
                .build();

        OkHttpUtils.initClient(okHttpClient);
    }

    public static MyApplication getInstant(){
        return myApplication;
    }
}
